<template>
  <div>
    <el-form>
      <h3>修改产品分类</h3>
      <el-form-item label="产品分类名称 :">
        <el-input v-model="classify.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="modifyClassify"
        >修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import api from "../../../network/apis/api.js";
export default {
  data() {
    return {
      classify: {
        _id: "",
        name: "",
      },
    };
  },
  mounted() {
    this.upClassify();
  },
  methods: {
    async upClassify() {
      const { data } = await api.classify.getOneClassify(
        this.$route.params._id
      );
      if (data.status) {
        this.classify = data.data;
      }
    },
    async modifyClassify() {
      const { data } = await api.classify.updataClassify(this.classify);
      if (data.status) {
        this.$message({
          message: "修改成功",
          type: "success",
        });
        this.$router.push("/admin/classifyList");
      }
    },
  },
};
</script>

<style>
.el-form {
  width: 320px;
  height: 200px;
  text-align: center;
  margin: 50px auto;
  border: 1px solid #d3d3d3;
}
.el-input {
  width: 200px;
}
h3 {
  padding-bottom: 20px;
}
</style>
